import request from '@/utils/request'
import {encodeParams} from '@/utils'


//获取角色列表
export function getRoleList(data) {
  return request({
    url: `/api/role?${encodeParams(data)}`,
    method: 'GET'
  })
}

//获取角色信息
export function getRoleInfo(id) {
  return request({
    url: `/api/role/get/${id}`,
    method: 'GET'
  })
}

//获取树状菜单
export function getPrivilegeList() {
  return request({
    url: '/api/role/getMenus',
    method: 'GET'
  })
}

//获取id关联菜单信息
export function getMenusListByRoleId(id) {
  return request({
    url: `/api/role/getMenusByRoleId/${id}`,
    method: 'GET'
  })
}


// 添加 编辑角色
export function createRole(data) {
  debugger
  return request({
    url: '/api/role',
    method: 'POST',
    data
  })
}

export function updateRole(id,data) {
  return request({
    url: `/api/role/${id}`,
    method: 'PUT',
    data
  })
}

//删除角色
export function deleteRole(id) {
  return request({
    url: `/api/role/delete/${id}`,
    method: 'GET'
  })
}
